  <?php 

//$username = $_GET['username'];
$group_id = $_GET['group_id'];
//$username='trang';
$actives = ($_GET['actives']!='false')? "'Active', ": "";
$pendings = ($_GET['pendings']!='false')? "'Pending', ": "";
$solds = ($_GET['solds']!='false')? "'Sold'": "";

$in = $actives.$pendings.$solds;

$in = trim($in);
$in = rtrim($in, ',');
$in = "(".$in.")";

//echo $in."<br>";

include("../db/opendb.php");

include("functions.php");

$gquery = "select u.Username as group_user, g.User_ID from Network_Groups_Users g inner join Users u on g.User_ID = u.ID where g.Group_ID = '".$group_id."' ";

//echo $gquery; echo "<br>";
$gresult = mysql_query($gquery) or die ("SQL Error".mysql_error());

$num_group_users = mysql_num_rows($gresult);

$xml_output = "<entries>\n"; 

$group_users .= "(";
$i = 0;
//echo $num_group_users;

while($grow=mysql_fetch_assoc($gresult))
{
$group_users .= "'".$grow['group_user']."'";
if($i < ($num_group_users-1)){
//echo $i;
$group_users .= ",";
}
$i++;
}

$group_users .= ")";

//echo "group_users = ".$group_users."<br>";

//while($grow=mysql_fetch_assoc($gresult))
//	{

//$query = "select u.Username, i.Path as IMAGE, l.OID, l.TITLE, l.LISTSTATUS, l.STREETNUM, l.STREETDIR, l.STREETNAME, l.STREETSUFFIX, l.CITY, l.STATE, l.BEDS, l.BATHSTOTAL, l.SQFTTOTAL, l.PARKINGCOVERED, l.LISTPRICE from PROPERTIES l inner join Prop_Owner_Con p on p.Prop_OID = l.OID inner join Users u on u.ID = p.Owner left join Listing_Images i on (i.Listing_ID = l.OID and i.Main_Photo = 1) where u.Username = '".$grow['group_user']."' and l.LISTSTATUS in ".$in." order by l.LISTSTATUS";

$query = "select u.Username, i.Path as IMAGE, l.OID, l.TITLE, l.DATE_POSTED, l.LISTSTATUS, l.STREETNUM, l.STREETDIR, l.STREETNAME, l.STREETSUFFIX, l.CITY, l.STATE, l.BEDS, l.BATHSTOTAL, l.SQFTTOTAL, l.PARKINGCOVERED, l.LISTPRICE from PROPERTIES l inner join Prop_Owner_Con p on p.Prop_OID = l.OID inner join Users u on u.ID = p.Owner left join Listing_Images i on (i.Listing_ID = l.OID and i.Main_Photo = 1) where u.Username in ".$group_users." and l.LISTSTATUS in ".$in." order by l.DATE_POSTED DESC";

//echo $query; echo "<br>";

$result = mysql_query($query) or die ("SQL Error".mysql_error());

$xml = getXML_group($result);

$xml_output .= $xml;
//}

$xml_output .= "</entries>";  

echo $xml_output;

?>
